//package com.sharding.config;
//
//import com.google.common.base.Preconditions;
//import groovy.lang.Closure;
//import groovy.util.Expando;
//import io.shardingsphere.core.api.algorithm.sharding.ListShardingValue;
//import io.shardingsphere.core.api.algorithm.sharding.PreciseShardingValue;
//import io.shardingsphere.core.api.algorithm.sharding.ShardingValue;
//import io.shardingsphere.core.api.algorithm.sharding.complex.ComplexKeysShardingAlgorithm;
//import io.shardingsphere.core.api.config.strategy.InlineShardingStrategyConfiguration;
//import io.shardingsphere.core.util.InlineExpressionParser;
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.LinkedList;
//import java.util.List;
//import java.util.TreeSet;
//import org.springframework.util.CollectionUtils;
//
//public class ModuloDatabaseShardingAlgorithm implements ComplexKeysShardingAlgorithm {
//
////  @Override
////  public Collection<String> doSharding(final Collection<String> availableTargetNames, final Collection<ShardingValue> shardingValues) {
////    ShardingValue shardingValue = shardingValues.iterator().next();
////    Preconditions.checkState(shardingValue instanceof ListShardingValue, "Inline strategy cannot support range sharding.");
////    Collection<String> shardingResult = doSharding((ListShardingValue) shardingValue);
////    Collection<String> result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
////    result.addAll(shardingResult);
////    return result;
////  }
////
////  private Collection<String> doSharding(final ListShardingValue shardingValue) {
////    Collection<String> result = new LinkedList<>();
////    for (PreciseShardingValue<?> each : transferToPreciseShardingValues(shardingValue)) {
////      result.add(execute(each));
////    }
////    return result;
////  }
////
////  @SuppressWarnings("unchecked")
////  private List<PreciseShardingValue> transferToPreciseShardingValues(final ListShardingValue<?> shardingValue) {
////    List<PreciseShardingValue> result = new ArrayList<>(shardingValue.getValues().size());
////    for (Comparable<?> each : shardingValue.getValues()) {
////      result.add(new PreciseShardingValue(shardingValue.getLogicTableName(), shardingValue.getColumnName(), each));
////    }
////    return result;
////  }
////
////  private String execute(final PreciseShardingValue shardingValue) {
////    Closure<?> result = closure.rehydrate(new Expando(), null, null);
////    result.setResolveStrategy(Closure.DELEGATE_ONLY);
////    result.setProperty(shardingValue.getColumnName(), shardingValue.getValue());
////    return result.call().toString();
////  }
//}
